package com.health.viewscontrols.jkjy;

import com.health.viewscontrols.NovaActivity;
import com.health.viewscontrols.NovaApplication;
import com.health.R;
import com.health.adapter.JKJYAdapter;
import com.health.tablebean.ARCHIVE_BASEINFO;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;

/**
 * 健康教育
 * 
 * @author nova
 *
 */
public class JKJYMainActivity extends NovaActivity {
	private GridView gd_menu;
	private JKJYAdapter menuAdapter;
	private TextView tv_name;

	private ARCHIVE_BASEINFO userinfo = null;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sbcl_main);
		userinfo = NovaApplication.getUserInfo();
		findViews();
		setListeners();
	}

	@Override
	public void findViews() {
		tv_name = (TextView) findViewById(R.id.tv_name);
		tv_name.setText("欢迎  " + userinfo.getCUSTOMERNAME());
		gd_menu = (GridView) findViewById(R.id.gd_menu);
		menuAdapter = new JKJYAdapter(getApplicationContext());
		gd_menu.setAdapter(menuAdapter);

	}

	@Override
	public void setListeners() {
		// 菜单选项
		gd_menu.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
				// 0孕妇 1儿童 2老年人
				Intent intent = null;
				if (position == 0) {
					// 0 孕妇
					intent = new Intent(getApplicationContext(), PlayVideoActivity.class);
					intent.putExtra("flag", "yunfu");
					startActivity(intent);
				} else if (position == 1) {
					// showTextDialog("暂无相关视频");
					intent = new Intent(getApplicationContext(), PlayVideoActivity.class);
					intent.putExtra("flag", "ertong");
					startActivity(intent);
				} else if (position == 2) {
					// showTextDialog("暂无相关视频");
					intent = new Intent(getApplicationContext(), PlayVideoActivity.class);
					intent.putExtra("flag", "laoren");
					startActivity(intent);
				} else if (position == 3) {
					JKJYMainActivity.this.finish();
				}
			}
		});

	}

}
